<%--
  Created by IntelliJ IDEA.
  User: jali
  Date: 2018/12/4
  Time: 23:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <%
        pageContext.setAttribute("APP_PATH",request.getContextPath());
    %>
    <%--
        web路径：
        不以/开始的相对路径，找资源，以当前资源的路径为基准，经常容易出问题。
        以/开始的相对路径，找资源，以服务器的路径为标准（http://localhost:8080）
        http://localhost:8080/curd
    --%>
    <script type="text/javascript" src="${APP_PATH}/static/js/jquery-1.12.4.min.js"></script>
    <link href="${APP_PATH}/static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="${APP_PATH}/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>


<div class="container">
    <%--标题--%>
    <div class="row">
        <div class="col-md-12">
            <h1>ssm-crud</h1>
        </div>
    </div>

    <%--按钮--%>
    <div class="row">
        <div class="col-md-4 col-md-offset-10">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>

    <%--显示表格数据--%>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <tr>
                    <th>#</th>
                    <th>name</th>
                    <th>sex</th>
                    <th>email</th>
                    <th>deptName</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="emp">
                    <tr>
                        <td>${emp.id}</td>
                        <td>${emp.empname}</td>
                        <td>${emp.sex}</td>
                        <td>${emp.email}</td>
                        <td>${emp.dept.deptname}</td>
                        <td>
                            <button class="btn btn-primary">编辑</button>
                            <button class="btn btn-danger">删除</button>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
    <%--分页--%>
    <div class="row">
        <%--分页文字信息--%>
        <div class="col-md-6">
            当前第${pageInfo.pageNum}页 共${pageInfo.pages}页 总${pageInfo.total}条记录
        </div>

        <%--分页条信息--%>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <c:if test="${pageInfo.pageNum==1}">
                        <li class="disabled">
                            <a href="${APP_PATH}/emps?pn=1" aria-label="Previous">
                                <span aria-hidden="true">首页</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.pageNum!=1}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=1" aria-label="Previous">
                                <span aria-hidden="true">首页</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.hasPreviousPage}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=${pageInfo.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <C:forEach items="${pageInfo.navigatepageNums}" var="num">
                        <c:if test="${pageInfo.pageNum == num}">
                            <li class="active"><a href="${APP_PATH}/emps?pn=${num}">${num}</a></li>
                        </c:if>
                        <c:if test="${pageInfo.pageNum != num}">
                            <li><a href="${APP_PATH}/emps?pn=${num}">${num}</a></li>
                        </c:if>
                    </C:forEach>
                    <c:if test="${pageInfo.hasNextPage}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=${pageInfo.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.pages==pageInfo.pageNum}">
                        <li class="disabled">
                            <a href="${APP_PATH}/emps?pn=${pageInfo.pages}" aria-label="Next">
                                <span aria-hidden="true">末页</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.pages!=pageInfo.pageNum}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=${pageInfo.pages}" aria-label="Next">
                                <span aria-hidden="true">末页</span>
                            </a>
                        </li>
                    </c:if>
                </ul>
            </nav>
        </div>
    </div>


</div>
</body>
</html>
